package com.spa.interfaces.shop;

import com.spa.application.dto.PageResult;
import com.spa.application.dto.shop.*;
import com.spa.application.query.shop.*;
import com.spa.application.service.ShopApplicationService;
import com.spa.application.service.shop.ShopIndexService;
import com.spa.infrastructure.common.ResponseMessage;
import com.spa.interfaces.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shop/index")
public class ShopIndexController extends BaseController {

    @Autowired
    private ShopIndexService shopIndexService;
    @Autowired
    private ShopApplicationService shopApplicationService;

    @PostMapping
    public ResponseMessage<IndexDTO> index(@Validated @RequestBody IndexDataQuery query) {
        return responseHelper.success(shopIndexService.index(query));
    }

    @PostMapping("queryServiceList")
    public ResponseMessage<List<ShopServiceDTO>> queryServiceList() {
        return responseHelper.success(shopApplicationService.serviceList());
    }

    @PostMapping("shopFeedbackPage")
    public ResponseMessage<PageResult<ShopFeedbackDTO>> shopFeedbackPage(@Validated @RequestBody ShopFeedbackQuery query) {
        return responseHelper.success(shopApplicationService.shopFeedbackPage(query));
    }

}
